﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using Microsoft.HomeServer.SDK.Interop.v1;

namespace Umbrella.Whs.Service.Activities
{

    public sealed class TimedWhsNotification : SafeCodeActivity
    {

        [RequiredArgument]
        public InArgument<string> NotificationId { get; set; }

        [RequiredArgument]
        public InArgument<WHS_Notification_Severity> Severity { get; set; }

        [RequiredArgument]
        public InArgument<string> Title { get; set; }

        [RequiredArgument]
        public InArgument<string> Description { get; set; }

        [RequiredArgument]
        public InArgument<TimeSpan> TimeSpan { get; set; }

        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        protected override void ExecuteSafe(CodeActivityContext context)
        {
            var id = context.GetValue(this.NotificationId);

            var not = new WhsNotification(id)
            {
                Title = context.GetValue(this.Title),
                Description = context.GetValue(this.Description),
                Severity = context.GetValue(this.Severity),
            };

            not.ShowNotification(context.GetValue(this.TimeSpan));
        }
    }
}
